package com.dtx.practice.three;

import org.junit.Test;

public class DemoTest {

    static class A{
        protected int value;
        public A(int v){
            setValue(v);
        }

        public void setValue(int value) {
            this.value = value;
        }
        public int getValue(){
            try{
                value++;
                return value;
            }finally {
                this.setValue(value);
                System.out.println(value);
            }
        }
    }

    static class B extends A{
        public B(){
            super(5);
            setValue(getValue() - 3);
        }

        @Override
        public void setValue(int value) {
            super.setValue(2 * value);
        }
    }

    @Test
    public void test(){
        System.out.println(new B().getValue());
    }
}
